//
//  DescribeVC.m
//  MyProject
//
//  Created by jiaming yan on 2017/9/13.
//  Copyright © 2017年 yanjiaming. All rights reserved.
//

#import "DescribeVC.h"
#import "IQTextView.h"

@interface DescribeVC ()
@property (weak, nonatomic) IBOutlet IQTextView *desTextView;

@end

@implementation DescribeVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"编辑自我描述";
    self.view.backgroundColor = kWhiteColor;
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:@"保存" forState:UIControlStateNormal];
    [button setTitleColor:UIColorFromRGB(0x13bacd) forState:UIControlStateNormal];
    button.titleLabel.font = k15Font;
    button.frame = CGRectMake(0, 0, 40, 40);
    [button addTarget:self action:@selector(saveButtonClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *barItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                       target:nil action:nil];
    
    negativeSpacer.width = -10;
    self.navigationItem.rightBarButtonItems = @[negativeSpacer,barItem];
    if (IOS11Later) {
        button.contentHorizontalAlignment =UIControlContentHorizontalAlignmentRight;
    }
    
    self.desTextView.placeholder = @"详细描述一下自己,字数控制在10-800字";

    if (self.model.seltDescription.length != 0) {
        self.desTextView.text = self.model.seltDescription;
    }
}
-(void)saveButtonClick{
    
    NSString *strAlert = @"";
    
    if (self.desTextView.text.length == 0) {
        strAlert = @"请输入自我描述";
    }
    
    if (strAlert.length != 0) {
        [CommonUtils showToast:strAlert];
        return;
    }
    
    NSLog(@"保存点击");
    //    NSString *strResumeId = self.str
    NSMutableDictionary *dicInfoParams = [[NSMutableDictionary alloc]initWithObjectsAndKeys:
                                          self.desTextView.text,@"seltDescription",
                                          nil];
    //简历id设置
    if (self.model.resumeId !=0) {
        [dicInfoParams setObject:[NSString stringWithFormat:@"%zd",self.model.resumeId] forKey:@"resumeId"];
    }
    //dicInfoParams转json
    
    [self showProgressWithView:self.view animated:YES];
    [YJMSendRequest postDataWithParameters:dicInfoParams url:@"resume/updateResume" result:^(NSDictionary *result, NSError *error) {
        result = [CommonUtils decryptDicWithResult:result];
        [self hideProgress:self.view animated:YES];
        if([result[@"result"] integerValue] == 1)
        {
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            [CommonUtils showToast:[result objectForKey:@"msg"]];
        }
    }];

}

- (IBAction)btnDeleteOnClick:(id)sender {
    

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
